class Article < ActiveRecord::Base
  belongs_to :article_category
  has_one :article_content,:dependent=>:delete
  before_save :save_image
  attr_accessor :image
  validates_presence_of :title,:article_category_id

  protected
  def save_image
    unless @image.blank?    
      self.image_name=CommonFunction.upload_file(@image,"/public/images/newsimgs/")
      CommonFunction.get_thumnb("/public/images/newsimgs/#{self.image_name}",140,true)
    end
  end
end
